<?php
  error_reporting(0);
  session_start();
# if ($_SESSION["autenticado"]!= 1 || $_POST["a"] == ""){
#   header ("Location: index.php");
# }
  ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es" dir="ltr">
  <head>
    <title>Pagar - PowerLaptops</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="default.css" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.tools.min.js"></script>
  </head>
  <body>
<?php
  include("top_1-06-2011.php");
  include('left.php');
  include_once("fachadaBD.php");
  $f = new fachadaBD();
  $compra= mysql_fetch_array($f->getBuy($_POST["a"],$_SESSION["usuario"]));
  if ($compra["PRODUCTO"] == ""){
    header ("Location: index.php");
  }
  $row = mysql_fetch_array($f->obtenerProducto($compra["PRODUCTO"]));
?>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Deposito</title>
  </head>
  <body>
	<div id="contentC" style="width: 780px;">
    <form name="pagar" action="guardarPago.php" method="POST">
      <table style="width: 780px;">
        <tr><td>
          <div id="contenido" style="width: 100%">
            <input type="hidden" name="id" value="<?php echo $compra["ID"] ?>"/>
            <table>
                <tr>
                  <td class="panelC" style="color: #EF7100">
                    <b>Su producto elegido:</b>
                  </td>
                </tr>
                <tr>
                  <td rowspan="0" style="border: 0x; margin: 0px;">
                    <img width ="180" src="<? echo $row["IMAGENGRANDE"]; ?>" />
                  </td>
                  <td>
                    <table cellspacing="4">
                      <tr>
                        <td class="panelC">
                          <b>Producto:</b>
                          <?
                            echo $row["MARCA"]." ".$row["MODELO"];
                          ?>
                        </td>
                        <td class="panelC" style="padding-left: 10px;">
                          <b> Cantidad: </b>
                          <?
                            echo $compra["CANTIDAD"];
                          ?>

                        </td>
                      </tr>
                      <tr>
                        <td class="panelC">
                          <b> Precio por unidad: </b>
                          <?
                            echo $row["PRECIO"]." Bs.";
                          ?>
                        </td>
                        <td class="panelC">
                          <b>Total: </b>
                           <?
                            echo $compra["CANTIDAD"]*$row["PRECIO"];
                          ?>
                          Bsf. <span style="font-size: 10px;">(incluye IVA)</span>
                        </td>
                      </tr>
                      <tr>
                        <td class="panelC">
                          <b>Tipo de Entrega:</b>
                          <?
                              if ($row["ENVIO"]=="diasiguiente"){
                                echo "Dia siguiente";
                              }
                              elseif($row["ENVIO"]=="inmediato"){
                                echo "Inmediato";
                              }
                          ?>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
            </table>
          </div>
        </td></tr>
        <tr><td height="2px"></td></tr>
        <tr><td>
          <?php
            include("pago.php");
          ?>
        </td></tr>
        <tr><td height="2px"></td></tr>
        <tr><td>
          <?php
            include("envio.php");
          ?>
        </td></tr>
        <tr><td height="2px"></td></tr>
        <tr><td>
        <div id="contenido" style="width: 100%;">
          <table>
            <tr>
              <td class="panelC" style="color: #EF7100">
                <b>Introduzca los datos para facturaci&oacute;n:</b>
              </td>
            </tr>
            <tr>
              <td>
                Nombre/Raz&oacute;n Social:
              </td>
              <td class="pago2" align="right">
                <input type="text" name ="nomFac" onkeypress="return noNumber(event)"/>
              </td>
            </tr>
            <tr>
              <td id="nomFac" class="hid">
                *Introduzca Nombre/Raz&oacute;n Social.
              </td>
            </tr>
            <tr>
              <td>
                Apellido:
              </td>
              <td class="pago2" align="right">
                <input type="text" name ="apeFac" onkeypress="return noNumber(event)"/>
              </td>
            </tr>
            <tr>
              <td id="apeFac" class="hid">
                *Introduzca Apellido.
              </td>
            </tr>
            <tr>
              <td>
                C&eacute;dula/Rif:
              </td>
              <td class="pago2" align="right">
                <input type="text" name="ciFac" onkeypress="return verifCIF(event)" size="8"/>
              </td>
            </tr>
            <tr>
              <td id="ciFac" class="hid">
                *Introduzca C&eacute;dula/Rif.
              </td>
            </tr>
            <tr>
              <td class="envio">
                Direcci&oacute;n Fiscal:
              </td>
              <td class="pago2" align="right">
                <input type="text" name="dirFac"/>
              </td>
            </tr>
            <tr>
              <td id="dirFac"class="hid">
                Introduzca su Direcci&oacute;n Fiscal.
              </td>
            </tr>
          </table>
    <div class="exTel">
      ejemplo: casa o local, calle, urbanizaci&oacute;n, sector, ciudad, estado.
     </div>
          </div>
        </td></tr>
        <tr><td height="2px"></td></tr>
        <tr><td>
        <div id="contenido" style="width: 100%;font-size: 10px;">
          <table>
            <tr>
              <td>
                <font style="color:red; font-size: 15px;">
                  <b> ATENCION: </b>
                </font>
              </td>
            </tr>
            <tr>
              <td>
                -Una vez envidoos sus datos de pago el mismo ser&aacute; confirmado durante los
                siguientes 30 minutos y le ser&aacute; enviado a su correo la confirmaci&oacute;n
                del mismo.
              </td>
            </tr>
            <tr>
              <td>
                -Si usted eligi&oacute; envio nacional: Una vez realizado el env&iacute;o de su producto,
                el n&uacute;mero de rastreo o "Tracking" ser&aacute; enviado a su correo a las 11:00pm.
                del mismo d&iacute;a.
              </td>
            </tr>
            <tr>
              <td>
                -Si usted eligi&oacute; retiro personal: Una vez confirmada la informaci&oacute;n de pago
                se le envia a su correo autom&aacute;ticamente la direcci&oacute;n en detalle para reatirar
                su producto.
              </td>
            </tr>
            <tr>
              <td>
                -Los usuarios que no concreten su intenci&oacute;n de compra en 3 oportunidades ser&aacute;n
                bloqueados de nuestra web.
              </td>
            </tr>
          </table>

          <br/>
          <img style="cursor: pointer; padding-left: 10px;padding-bottom: 5px;" onclick="verificar()" src="images/enviar-datos-pago.jpg"/>
  <!--    <input type="image" src="images/BotonComprar.gif" onclick="javascript:verificar()"> -->
          <br/>
          <input type="checkbox" name="read"/>
          He le&iacute;do y acepto las Pol&iacute;ticas de Ventas y las Pol&iacute;ticas de Entregas
          y Env&iacute;os
          <br/>
          <span class="hid" id ="rread">
            *Lea las pol&iacute;ticas de ventas y las pol&iacute;ticas de entrega y envio.
          </span>
  <!--
          <table>
            <tr>
              <td>
                <button type="submit" onclick="verificar()">Enviar datos de pago</button>
              </td>
            </tr>
            <tr>
              <td>
                <input type="checkbox" name="read">
              </td>
              <td>
                He le&iacute;do y acepto las Pol&iacute;ticas de Ventas y las Pol&iacute;ticas de Entregas
                y Env&iacute;os
              </td>
            </tr>
          </table>
  -->
        </div>
        </td></tr>
        <tr><td height="2px"></td><tr>
        </table>
      </form>
    </div>
    <script language="JavaScript" type="text/javascript">

     function verifCIF(evt){
        var key = evt.charCode;
        if (key == 0)
          return true;
        if (document.pagar['ciFac'].value.length == 8)
          return false;
        if ((48 <= key && key <= 57)){
          return true;
        }
        return false;
     }			

      function verifCI(evt){
        var key = evt.charCode;
        if (key == 0)
          return true;
        if (document.pagar['ci'].value.length == 8)
          return false;
        if ((48 <= key && key <= 57)){
          return true;
        }
        return false;
      }

      function noNumber(evt){
        var key = evt.charCode;
        if ((65 <= key && key <= 90) ||
             key ==241 ||
             key == 32 ||
             (97 <= key && key <= 122) ||
             key == 0){
          return true;
        }
        return false;
      }

      function verificar(){
        lcod = new Array("0414","0412","0416","0424","0426","0212","0248","0281","0283","0282","0285","0292","0240","0247","0277","0278","0243","0244","0246","0273","0278","0284","0285","0286","0288","0289","0241","0242","0243","0245","0249","0258","0287","0259","0268","0269","0279","0235","0238","0246","0247","0251","0252","0253","0271","0274","0275","0234","0239","0291","0292","0287","0295","0255","0256","0257","0272","0293","0294","0275","0276","0277","0271","0272","0253","0254","0261","0262","0263","0264","0265","0266","0271");
        com = true;
        if(!document.pagar.read.checked){
          com = false;
          document.getElementById('rread').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('rread').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.nomFac.value == ""){
          com = false;
          document.getElementById('nomFac').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('nomFac').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.apeFac.value == ""){
          com = false;
          document.getElementById('apeFac').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('apeFac').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.ciFac.value == ""){
          com = false;
          document.getElementById('ciFac').innerHTML="*Introduzca su cédula/Rif.";
          document.getElementById('ciFac').setAttribute('style','visibility: visible');
        }else if (document.pagar.ciFac.value.length < 4){
          document.getElementById('ciFac').innerHTML="*Introduzca una cédula/Rif valida.";
          document.getElementById('ciFac').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('ciFac').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.dirFac.value == ""){
          com = false;
          document.getElementById('dirFac').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('dirFac').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.pers.value == ""){
          com = false;
          document.getElementById('pers').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('pers').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.ci.value == ""){
          com = false;
          document.getElementById('ci').innerHTML="*Introduzca cédula.";
          document.getElementById('ci').setAttribute('style','visibility: visible');
        }else if (document.pagar.ci.value.length < 4){
          document.getElementById('ci').innerHTML="*Introduzca una cédula valida.";
          document.getElementById('ci').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('ci').setAttribute('style','visibility: hidden');
        }
        if (document.pagar.telefono.value ==""){
          document.getElementById('telefono').innerHTML="*Introduzca teléfono.";
          document.getElementById('telefono').setAttribute('style','visibility: visible');
        }else if(document.pagar.telefono.value.length != 11){
          document.getElementById('telefono').innerHTML="*Introduzca un télefono válido, quizas le falta codigo de area, siga el ejemplo.";
          document.getElementById('telefono').setAttribute('style','visibility: visible');
        }else{
          find= false;
          cod = document.pagar.telefono.value.substring(0,4);
          for(i = 0 ; i <lcod.length && !find;i++){
            if (lcod[i] == cod){
              find = true;
              telcod = false;
            }
          }
          if (!find){
            document.getElementById('telefono').innerHTML="*codigo de area invalido.";
            document.getElementById('telefono').setAttribute('style','visibility: visible');
            com = false;
          }
          else{
          document.getElementById('telefono').setAttribute('style','visibility: hidden');
          }
        }
        if (document.pagar.numTrans.value == ""){
          com = false;
            document.getElementById('num').innerHTML="*Falta campo por rellenar.";
          document.getElementById('num').setAttribute('style','visibility: visible');
        }else if (document.pagar.numTrans.value.length <4){
          com = false;
            document.getElementById('num').innerHTML="*numero invalido.";
          document.getElementById('num').setAttribute('style','visibility: visible');
        }else{
          document.getElementById('num').setAttribute('style','visibility: hidden');
        }
        if (com){
          document.pagar.submit();
        }
      }

    </script>
  </div>
    <?php
      include("low.php");
    ?>
  </body>
</html>
